/** 
Copyright (c) 2010, Sheikh Abdul Wahid Ahmed
Details @ http://extremecodeworld.codeplex.com/license
**/

using System;
 using System.Data;
namespace EXtremecode.Utils
{
    /// <summary>
    /// Summary description for DataAccessorUtil.
    /// </summary>
    public class DataAccessorUtil
    {
        public static void MakeCloneOfCommand(IDbCommand source, IDbCommand clonedShell)
        {
            clonedShell.CommandText = source.CommandText;
            clonedShell.CommandType = source.CommandType;
            foreach (IDbDataParameter sourceParam in source.Parameters)
            {
                IDbDataParameter param = clonedShell.CreateParameter();
                MakeCloneOfParameter(sourceParam, param);
                clonedShell.Parameters.Add(param);
            }
        }

        public static void MakeCloneOfParameter(IDbDataParameter source, IDbDataParameter clonedShell)
        {
            clonedShell.DbType = source.DbType;
            clonedShell.Direction = source.Direction;
            clonedShell.ParameterName = source.ParameterName;
            clonedShell.Precision = source.Precision;
            clonedShell.Scale = source.Scale;
            clonedShell.Size = source.Size;
            clonedShell.SourceColumn = source.SourceColumn;
            clonedShell.SourceVersion = source.SourceVersion;
            clonedShell.Value = source.Value;
        }
    }
}

